package com.jml.spring.resource;

import java.io.InputStream;

public class ClasspathResource implements Resource{
    private String location ;

    public ClasspathResource(String location) {
        this.location = location;
    }

    @Override
    public InputStream getInputStream() {
        if (location.startsWith("classpath:")){
            location = location.substring(10);
        }
        // 读取classpath路径资源的方式
        return this.getClass().getClassLoader().getResourceAsStream(location);
    }
}
